/*
 * Copyright(c) 2018-? the original author[Wien(luweien@aliyun.com)] or authors.
 *
 */
package org.doll.it.sequence.enums;

/**
 * 业务类型
 * 
 * @author Wien(luweien@aliyun.com)
 *
 */
public enum BusinessTypeEnum {

	/** 默认 */
	DEFAULT(0, "默认"),

	// nora模块：1-19
	/** 内核Nora模块 */
	NORA(1, "内核Nora模块"),
	/** 内核Nora模块之Blob */
	NORA_BLOB(2, "内核Nora模块之Blob"),
	/** 内核Nora模块之Tree */
	NORA_TREE(3, "内核Nora模块之Tree"),
	/** 内核Nora模块之提交 */
	NORA_COMMIT(4, "内核Nora模块之提交"),
	/** 内核Nora模块之Head */
	NORA_HEAD(5, "内核Nora模块之Head"),
	/** 内核Nora模块之快照 */
	NORA_SNAPSHOT(6, "内核Nora模块之快照"),
	/** 内核Nora模块之标签 */
	NORA_TAG(7, "内核Nora模块之标签"),
	/** 内核Nora模块之备份 */
	NORA_BACKUP(8, "内核Nora模块之备份"),

	// linde模块：20-39
	/** 内核Linde模块 */
	LINDE(20, "内核Linde模块"),
	/** 内核Linde模块之状态 */
	LINDE_STATE(21, "内核Linde模块之状态"),
	/** 内核Linde模块之字段 */
	LINDE_FIELD(22, "内核Linde模块之字段"),
	/** 内核Linde模块之附件 */
	LINDE_ATTACHMENT(23, "内核Linde模块之附件"),
	/** 内核Linde模块之类型 */
	LINDE_TYPE(24, "内核Linde模块之类型"),

	// web模块：40-59
	/** Web模块之会话类型 */
	WEB_SESSION(40, "Web模块之会话类型"),
	/** Web模块之用户类型 */
	WEB_USER(41, "Web模块之用户类型");

	private final int code;

	private final String message;

	private BusinessTypeEnum(int code, String message) {
		this.code = code;
		this.message = message;
	}

	/**
	 * @return Return the integer value of this status code.
	 */
	public int getCode() {
		return code;
	}

	/**
	 * @return Return the reason phrase of this code.
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * Return the enum constant of this type with the specified numeric value.
	 * @param code
	 * @return
	 */
	public static BusinessTypeEnum valueOf(int code) {
		for (BusinessTypeEnum typeEnum : values()) {
			if (typeEnum.getCode() == code) {
				return typeEnum;
			}
		}
		throw new IllegalArgumentException("No matching constant for [" + code + "]");
	}
}
